<template>
  <!-- 责任区域树搜索 -->
  <tree-search
    v-bind="$attrs"
    v-on="$listeners"
    isAll
    ref="treeSearch"
    emptyDescription="暂无区域信息"
    :replaceFields="{ children: 'children', title: 'name', key: 'id' }"
    :api="apiTree"
    :selectedKeys.sync="selectedKeys"
    :selectOptions.sync="selectOptions"
  >

    <slot name="after" :data="data" slot="nameAfter" slot-scope="{data}" />
  </tree-search>
</template>

<script>
import TreeSearch from '@/components/businessComponents/TreeSearch' // 树
import { setSubItem } from '@/api/quality/currency' // api

export default {
  name: 'TreeInspection',
  components: {
    TreeSearch
  },
  props: {
    // 是否显示停用按钮的控件
    showEnabled: {
      type: Boolean,
      default: () => false
    }
  },
  computed: {
    // 树节点api
    apiTree() {
      return setSubItem
    },
  },
  data() {
    return {
      selectedKeys: {},
      selectOptions: {}
    }
  },
  methods: {
    // 渲染列表
    getList() {
      return this.$refs.treeSearch.getList()
    }
  },
  watch: {
    selectedKeys(e) {
      this.$emit('update:selectedKeys', e)
    },
    selectOptions(e) {
      this.$emit('update:selectOptions', e)
    }
  }
}
</script>
